package com.qike.duola.controller;

import com.qike.duola.response.BaseResult;
import com.qike.duola.response.RetResponse;
import com.qike.duola.service.DuolaTransOrderService;
import com.qike.duola.vo.GetAllFreeCarListVo;
import com.qike.duola.vo.GetLastTransOrderByCarIdVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: qike_duola
 * @author: Eric
 * @create: 2020-11-12 13:41
 */
@RestController
@RequestMapping("/wxController")
@Api(description = "微信控制器")
@CrossOrigin
public class WxController extends  BaseController {

    private static Logger logger = LoggerFactory.getLogger(WxController.class);

    @Autowired
    private DuolaTransOrderService duolaTransOrderService;


    /**
     * 通过车辆id获取最新运输单
     *
     * @return
     */
    @GetMapping("/getLastTransOrderByCarId")
    @ApiOperation("通过车辆id获取最新运输单")
    @ResponseBody
    @ApiResponses({
            @ApiResponse(code = 200, message = "ok", response = GetLastTransOrderByCarIdVo.class)
    })
    public BaseResult getLastTransOrderByCarId(Integer carId,Double lat,Double lng) {
        try {
            GetLastTransOrderByCarIdVo vo = duolaTransOrderService.getLastTransOrderByCarId(carId,lat,lng);
            return RetResponse.makeOKRsp(vo);
        } catch (Exception e) {
            logger.error(e.getMessage());
            return RetResponse.makeErrRsp(e.getMessage());
        }
    }
}